import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib as mpl


class PlotBox(object):
    def __init__(self):
        # matplotlib中文显示方块
        mpl.rcParams['font.sans-serif'] = ['SimHei']  # 指定默认字体
        mpl.rcParams['axes.unicode_minus'] = False  # 解决保存图像是负号'-'显示为方块的问题
        self.plt = mpl.pyplot

    def seanborn_box(self):
        """
        箱须图
        :return:
        """
        tips = pd.read_csv('./data/tips.csv')
        # 画图
        # 箱线图
        sns.boxplot(x=tips['day'], y=tips['total_bill'])
        # 散点:注意，如果用scatterplot，将无法明显看出散点分布(有叠加)
        sns.swarmplot(x='day', y='total_bill', data=tips, color='0.25')
        # sns.scatterplot(x='day', y='total_bill', data=tips)

        self.plt.show()


plot_box = PlotBox()
plot_box.seanborn_box()
